<template>
    <h2>登录</h2>
    <table>
        <tr>
            <td>用户名</td>
            <td>
                <input type="text" v-model="Name">
            </td>
        </tr>
        <tr>
            <td>密码</td>
            <td>
                <input type="text" v-model="Pass">
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button" value="登录" @click="Login">
            </td>
        </tr>
    </table>
</template>
<script lang="ts" setup>
import { ref } from 'vue';


import axios from 'axios';
const Name = ref('');
const Pass = ref('');


const Login = () => {
    axios.get('http://localhost:25190/api/Demo/Login', {
        params: {
            Name: Name.value,
            Pass: Pass.value
        }
    })
        .then(res => {
            if (res.data == -1) {
                alert("用户不存在");
                return;
            }
            if (res.data == 333) {
                alert("登录成功");
                location.href = '/Show';

                return;
            }
            if (res.data == 0) {
                alert("状态错误");
                return;
            }
            if (res.data == 777) {
                alert("密码错误");
                return;
            }
        })

}


</script>